<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../lib/vue.js"></script>
</head>
<body>
    <div id="app">
        {{one | date | sliceNum(20)}}
    </div>
</body>
<script>
    // 串联：可以使用多个过滤器
    new Vue({
        el:"#app",
        data:{
            one:Date.now()
        },
        filters:{
            date(v){
                const timer = new Date(v);
                return timer.getFullYear()+"-"+
                    (timer.getMonth()+1).toString().padStart(2,0)+"-"+
                    timer.getDate().toString().padStart(2,0)+" "+
                    timer.getHours().toString().padStart(2,0)+":"+
                    timer.getMinutes().toString().padStart(2,0)+":"+
                    timer.getSeconds().toString().padStart(2,0);
            },
            sliceNum(v,n=2){
                return v.slice(0,n);
            }
        }
    })
</script>
</html>